<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<title>用户登录</title>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<![endif]-->
<meta name="description" content="Administry" />
<meta name="keywords" content="Admin,Template" />
<!-- Favicons --> 
<link rel="shortcut icon" type="image/png" HREF="images/icons/lock.png"/>
<link rel="icon" type="image/png" HREF="images/icons/lock.png"/>
<link rel="apple-touch-icon" HREF="images/icons/lock.png" />
<!-- Main Stylesheet --> 
<link rel="stylesheet" href="css/style.css" type="text/css" />
<!-- Your Custom Stylesheet --> 
<link rel="stylesheet" href="css/custom.css" type="text/css" />
<%@include file="/include/header.jsp" %>
<!-- jQuery with plugins -->
<script type="text/javascript" src="lib/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="lib/jquery/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="lib/jquery/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="lib/jquery/jquery.ui.tabs.min.js"></script>
<!-- Superfish navigation -->
<script type="text/javascript" src="lib/jquery/jquery.superfish.min.js"></script>
<script type="text/javascript" src="lib/jquery/jquery.supersubs.min.js"></script>
<!-- jQuery form validation -->
<script type="text/javascript" src="lib/jquery/jquery.validate_pack.js"></script>
<script src="<%=request.getContextPath()%>/lib/jquery/jquery.form.js"></script>
<script src="<%=request.getContextPath()%>/js/function.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	if(window.parent == window){//用于当登录页面在一个非框架页里打开时
		$("#top").show();
		$("#pagetitle").show();
		$("#bottom").show();
	}else{ //用于当登录页面在一个框架页里打开时，只显示部分内容
		<c:if test="${param.type != 3}">
			<c:if test="${param.type == 2}">$("#session_expire_box").html("您还未登录，请登录后继续");</c:if>
			$("#session_expire_box").show();
			$("#enter_username_box").hide();
		</c:if>
		<c:if test="${param.url != null}">
			var url = "<c:out value="${param.url}"/>";
		</c:if>
		<c:if test="${param.script}">
			//判断是否为异步登录，通常用于Session过期时登录
			$("#loginform").submit(function(){
				$("#loginform").ajaxSubmit(function(json){
					Ajax.callback(json, function(data, json){
						if(typeof(url) != "undefined"){
							location.href = url;
						}else{
							window.parent.scriptLoginCallback(data, json);
						}
					}, function(data, json){
						$("#session_expire_box").show();
						$("#enter_username_box").hide();
						if(data == "_script_login_error"){
							if(json.error){
								$("#session_expire_box").html(json.error);
							}else{
								$("#session_expire_box").html("登录失败，请重试！");
							}
						}
					});
				});
				return false;
			});
		</c:if>
	}
	/* setup navigation, content boxes, etc... */
	Administry.setup();
	
	var validator = $("#loginform").validate({
		rules: {
			j_username: "required",
			j_password: "required"
		},
		messages: {
			j_username: "请输入用户名",
			j_password: "请输入密码"
		},
		errorPlacement: function(error, element) {
			error.insertAfter(element.parent().find('label:first'));
		},
		success: function(label) {
			label.html("&nbsp;").addClass("ok");
		}
	});
	<c:choose>
		<c:when test="${SPRING_SECURITY_LAST_USERNAME != null}">
			$("#password").focus();
		</c:when>
		<c:otherwise>
			$("#username").focus();
		</c:otherwise>
	</c:choose>

	function layout(){
		var height = $(window).height();
		var topH = $("#top").outerHeight();
		var pagetitleH = $("#pagetitle").outerHeight();
		var bottomH = $("#bottom").outerHeight();
		var h = height - topH - pagetitleH - bottomH;
		$("#page").height(Math.max(h, 300));
	}

	$(window).resize(layout);
	layout();
});
</script>
</head>
<body>
	<!-- Header -->
	<header id="top" style="display:none;">
		<div class="wrapper-login">
			<!-- Title/Logo - can use text instead of image -->
			<div id="title"><span>后台管理系统</span> <small>Beta</small></div>
			<!-- Main navigation -->
			<nav id="menu">
				<ul class="sf-menu">
					<li class="current"><a href="#">登录</a></li>
					<li><a href="#">注册</a></li>
				</ul>
			</nav>
			<!-- End of Main navigation -->
			<!-- Aside links
			<aside><b>English</b> &middot; <a href="#">中文</a></aside>
			 -->
			<!-- End of Aside links -->
		</div>
	</header>
	<!-- End of Header -->
	<!-- Page title -->
	<div id="pagetitle" style="display:none;">
		<div class="wrapper-login"></div>
	</div>
	<!-- End of Page title -->
	
	<!-- Page content -->
	<div id="page">
		<!-- Wrapper -->
		<div class="wrapper-login">
				<!-- Login form -->
				<section class="full">
					
					<h3>用户登录</h3>
					<c:choose>
					<c:when test="${param.login_error != null}">
						<div class="box box-error">登录失败，<c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"></c:out></div>
					</c:when>
					<c:when test="${param.concurrency != null}">
						<div class="box box-error">此帐号已在其他地方登录，您被迫下线</div>
					</c:when>
					<c:otherwise>
						<div id="session_expire_box" class="box box-error" style="display:none;">会话已过期，请重新登录</div>
						<div id="enter_username_box" class="box box-info">请输入用户名密码</div>
					</c:otherwise>
					</c:choose>
					<form id="loginform" method="post" action="<%=request.getContextPath()%>/j_spring_security_check?mark=">

						<p>
							<label class="required" for="username">用户名:</label><br/>
							<input type="text" id="username" class="full" name="j_username" value='<c:out value="${SPRING_SECURITY_LAST_USERNAME}"/>' />
						</p>
						
						<p>
							<label class="required" for="password">密码:</label><br/>
							<input type="password" id="password" class="full" value="" name="j_password"/>
						</p>
						
						<p>
							<input type="checkbox" id="remember" class="" value="1" name="_spring_security_remember_me"/>
							<label class="choice" for="remember">两周内自动登录</label>
						</p>
						
						<p>
							<button type="submit" class="btn btn-green big"><span class="icon icon-key"></span>登录</button>
							 &nbsp; <button class="btn btn-blue big" type="reset">重置</button>
							 &nbsp; <a href="javascript: //;" onClick="$('#emailform').slideDown(); return false;">忘记密码?</a>
							 &nbsp; <a href="#">需要帮助?</a>
						</p>
						<div class="clear">&nbsp;</div>

					</form>
					
					<form id="emailform" style="display:none" method="post" action="#">
						<div class="box">
							<p id="emailinput">
								<label for="email">Email:</label><br/>
								<input type="text" id="email" class="full" value="" name="email"/>
							</p>
							<p>
								<input type="submit" class="btn" value="Send"/>
								<input type="submit" class="btn" value="Cancle" onclick="$('#emailform').slideUp(); return false;"/>
							</p>
						</div>
					</form>
					
				</section>
				<!-- End of login form -->
				
		</div>
		<!-- End of Wrapper -->
	</div>
	<!-- End of Page content -->
	
	<!-- Page footer -->
	<footer id="bottom" style="display:none;">
		<div class="wrapper-login">
			<div>Copyright &copy; 2012 <b>版权所有</b></div>
		</div>
	</footer>
	<!-- End of Page footer -->

<!-- User interface javascript load -->
<script type="text/javascript" src="js/administry.js"></script> 
</body>
</html>